//-----------------------------------------------------------------------
// <copyright file="CertificateService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class CertificateService
    {
        #region Certificate

        public static void CreateCertificate(Certificate certificate)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                certificateDAO.CreateCertificate(certificate);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateCertificateException, ex);
            }
        }        

        public static void UpdateCertificate(Certificate certificate)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                certificateDAO.UpdateCertificate(certificate);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateCertificateException, ex);
            }
        }        

        public static void DeleteCertificate(int certificateID)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                certificateDAO.DeleteCertificate(certificateID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteCertificateException, ex);
            }
        }
        
        public static Certificate GetCertificate(int certificateID)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                return certificateDAO.GetCertificate(certificateID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCertificateException, ex);
            }
        }                

        public static CertificateCollection GetCertificateList(CertificateColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                return certificateDAO.GetCertificateList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCertificateListException, ex);
            }
        }        

        public static CertificateCollection GetCertificateList(CertificateColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                return certificateDAO.GetCertificateList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCertificateListException, ex);
            }
        }        

	    public static CertificateCollection GetCertificateListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                return certificateDAO.GetCertificateListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCertificateListException, ex);
            }
        }        

        public static CertificateCollection GetCertificateListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                CertificateDAO certificateDAO = new CertificateDAO();
                return certificateDAO.GetCertificateListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCertificateListException, ex);
            }
        }        

        #endregion
    }
}